Configure Calculated Attribute: Variables
The Variables tab lets you define one or more variables to use in the Calculated Attribute's expression. Using variables is optional, but they can help make your expressions easier to read and maintain.
Define a Variable
To define a variable:
-
Navigate to the Variables tab of the Member Attribute Details screen.
-
In the Display Name field, enter a name for the variable.
Note: The platform automatically generates an Internal Name based on the Display Name by converting all upper-case letters to lower-case letters, and converting spaces to underscores. The resulting Internal Name will be used as the variable name when defining the Calculated Attribute expression. Once the variable is created, you can't later edit this Internal Name.
-
From the drop-down menu, select the Assignment Type for how the variable will be populated. These methods are described below in more detail.
-
Click Add Variable.
-
The system adds an area on the screen for defining the variable. Within this area, the Display Name and Assignment Type properties are populated based on what you entered above. Optionally, you can edit these properties as needed. In addition, the Internal Name is displayed, but this value can't be edited.
-
From the Data Type drop-down menu, select the variable's Data Type.
-
The Properties area is used to define how the variable is derived. The configuration options vary depending on the selected Assignment Type. See below for additional details on each of these Assignment Types.
-
Click Save.
-
Repeat the above steps as needed to define additional variables.
-
Optionally, to delete a variable, click the Delete link next to it.
-
Optionally, to view the underlying Groovy expression for a variable, click the Show Expression link. The Show Query pop-up window is displayed and populated with the expression. When finished, click Close.
Assignment Types
The Assignment Type defines how a variable is populated
Use a Groovy expression to populate the variable. Enter the expression in the code editor.
Populate the variable based on an aggregation of an Attribute at a Business Unit level. The Properties area provides the following configuration options:
-
Member Attribute: Select the Member Attribute to aggregate.
-
Aggregate Function: Select the aggregation method: Sum, Maximum, Minimum, or Average.
-
Business Unit: Optionally, select one or more Business Units to include in the aggregation. If you don't select any Business Units, the platform will automatically include all Business Units.
Populate the variable based on an aggregation of a Metric at a household level. The Properties area provides the following configuration options:
-
Metric: Select the desired Metric.
-
Metric Subtype: Select the desired Metric activity: Balance, Earn, Expire, or Redeem.
-
Aggregate Function: Select the aggregation method: Sum, Maximum, Minimum, or Average.
-
In Period: Optionally define a time period for Metric activities. The use of a time period is optional, but it is recommended for performance reasons. From the drop-down menu, select an operator:
-
Is Before: Enter the end date / time, and select a time zone. Optionally define a limit to the date period, such as "6 months," for example.
-
Is On or After: Enter the start date / time, and select a time zone.
-
Is Between: Enter the start date / time and the end date / time, and select a time zone.
-
Is In Last: Define a relative date period, such as "6 months," for example.
-
Is In Period: Select a relative date period: Week-to-date, Month-to-date, Quarter-to-date, or Year-to-date.
-
-
Include: Check household members to include: Self, Parent, Siblings, and / or Children.
The Filter section lets you optionally define logical conditions that select only specific records. To define a Filter:
-
Click the Add icon, then select Add Rule. The platform adds a new blank row.
-
The first drop-down menu is populated with all of the different object types in Loyalty that are available for use. From this drop-down menu, select one of the following object types to expand it and see the available options:
This option allows you to define a logical statement based on a value in a Member Attribute.
-
From the menu, select the desired Member Attribute.
-
Select a mathematical operator; the available operators will vary based on the Data Type of the item you selected above.
-
Enter or select a value.
This option allows you to define a logical statement based on a value in a Member Preference.
-
From the menu, select the desired Member Preference.
-
Select a mathematical operator.
-
Enter or select a value.
This option allows you to define a logical statement by performing a mathematical calculation on a selected Activity Type.
-
From the menu, select the desired calculation method: Aggregate, Count, or Recency.
-
From the second drop-down menu, select the desired Activity Type.
-
Select a mathematical operator.
-
Enter or select a value.
-
Based on the selected calculation method, the platform provides the option to enter additional criteria:
-
Count: Define a time period, such as "Is In Last 3 Months." The use of a time period is optional, but recommended to improve system performance.
-
Aggregate: Select how to perform the aggregation: either by picking an Attribute on which to aggregate, or by entering a Groovy expression. Select the Aggregate Function: Sum, Minimum, or Maximum. Define a time period, such as "Is In Last 3 Months." The use of a time period is optional, but recommended to improve system performance.
-
This option allows you to define a logical statement using a Member's history of Metric usage.
-
From the menu, select the desired usage type: Balance, Earn, Expire, or Redeem.
-
From the second drop-down menu, select the desired Metric.
-
Select a mathematical operator.
-
Enter or select a value.
-
For the Earn, Expire, and Redeem Metric usage types, define a time period, such as "Is In Last 3 Months." The use of a time period is optional, but recommended to improve system performance.
This option allows you to define a logical statement by referencing either a Lookup table or a Member Function.
-
From the menu, select either Lookup or Function.
-
From the second drop-down menu, select the desired Lookup table or Member Function.
-
Select a mathematical operator.
-
Enter or select a value.
-
If you selected a Lookup table and it has Parameters defined, select the Attribute on which to match.
-
If you selected a Member Function and it has Arguments defined, select the Attribute on which to match.
This option allows you to define a logical statement using a variable defined on the Variables tab. For more information, please see Configure a Calculated Attribute: Variables.
-
From the menu, select the desired variable.
-
Select a mathematical operator.
-
Enter or select a value.
-
Repeat the above steps as needed to define more Rules. Optionally, to remove a Rule, click the Remove icon next to it.
-
Optionally, you can also organize Rules into Rule Groups. A Rule Group allows you to build more complex selection criteria. To create a Rule Group, click the Add icon, then select Add Rule Group. The platform creates a Group, which is represented visually as a nested box with its own operator and Add icon. Within this Group box, click the Add icon to define the Rule (or Rules) using the same process as described above. Use the toggle within the Group box to define the logical operator for the Rules within the Group.
Note: By clicking the Group button inside the Group box, you can create "nested" groups.
Populate the variable based on a value in another Attribute. The Properties area provides the following configuration options:
-
Member Attribute: Select the desired Member Attribute.
Populate the variable based on a Member Metric. The Properties area provides the following configuration options:
-
Metric: Select the desired Metric.
Populate the variable based on a Lookup table. The Properties area provides the following configuration options:
-
Lookup: Select the desired Lookup table.
-
Value: If the Lookup table has more than one value, select the desired value.
-
Lookup Parameters: For each parameter in the Lookup table, select a matching Attribute.
Populate the variable based on a Member Function. The Properties area provides the following configuration options:
-
Function: Select the desired Member Function.
-
Function Parameters: For each argument in the Member Function, select an Attribute.
Populate the variable based on a calculation performed on a Member Metric. The Properties area provides the following configuration options:
-
Metric Activity: Select the desired Metric activity: Balance, Earn, Expire or Redeem.
-
Metric: Select the desired Metric.
-
In Period: For the Earn, Expire, and Redeem activities, you can optionally include only Activities that occurred within a specified time period. Select an operator, enter a number, then select an interval. For example: "Is In Last 3 Months."
Note: The use of a time period is optional, but it is recommended for performance reasons.
Populate the variable based on a relative date calculation. The Properties area provides the following configuration options:
-
Period Option: Select a relative period starting point:
-
Relative to Member Attribute: Select a date Attribute.
-
Relative to Now
-
Relative to Today
-
-
Period Length: Define the time offset, such as "Plus 6 Months" for example.